FROM ubuntu:22.04

LABEL maintainer="zxy <admin@zxy.com>"
LABEL description="Squid proxy with basic auth (zxy:zxy999)"

ENV TZ=Asia/Shanghai

# 安装 Squid 与认证工具
RUN apt-get update && apt-get install -y squid apache2-utils && apt-get clean

# 复制配置文件
COPY conf/squid.conf /etc/squid/squid.conf

# 创建认证文件
RUN htpasswd -cb /etc/squid/passwd zxy zxy999 && \
    chown proxy:proxy /etc/squid/passwd && chmod 640 /etc/squid/passwd && \
    mkdir -p /var/log/squid /var/cache/squid /var/run/squid && \
    chown -R proxy:proxy /var/log/squid /var/cache/squid /var/run/squid

EXPOSE 3128
CMD ["squid", "-N", "-d", "1"]
